You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mina.apache.org by ni...@apache.org on 2007/10/18 20:39:49 UTC
svn commit: r586063 [2/3] - in /mina/sandbox/niklas/mina-sm: ./
src/main/java/org/apache/mina/sm/
src/main/java/org/apache/mina/sm/annotation/
src/main/java/org/apache/mina/sm/context/
src/main/java/org/apache/mina/sm/event/ src/main/java/org/apache/mi...
Modified: mina/sandbox/niklas/mina-sm/src/main/java/org/apache/mina/sm/context/AbstractStateContextLookup.java
URL: http://svn.apache.org/viewvc/mina/sandbox/niklas/mina-sm/src/main/java/org/apache/mina/sm/context/AbstractStateContextLookup.java?rev=586063&r1=586062&r2=586063&view=diff
==============================================================================
--- mina/sandbox/niklas/mina-sm/src/main/java/org/apache/mina/sm/context/AbstractStateContextLookup.java (original)
+++ mina/sandbox/niklas/mina-sm/src/main/java/org/apache/mina/sm/context/AbstractStateContextLookup.java Thu Oct 18 11:39:46 2007
@@ -1,19 +1,20 @@
/*
- * @(#) $Id$
- *
- * Copyright 2004 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*
*/
package org.apache.mina.sm.context;
@@ -21,7 +22,7 @@
/**
*
*
- * @author The Apache Directory Project (mina-dev@directory.apache.org)
+ * @author The Apache MINA Project (dev@mina.apache.org)
* @version $Rev$, $Date$
*/
public abstract class AbstractStateContextLookup implements StateContextLookup {
Modified: mina/sandbox/niklas/mina-sm/src/main/java/org/apache/mina/sm/context/DefaultStateContext.java
URL: http://svn.apache.org/viewvc/mina/sandbox/niklas/mina-sm/src/main/java/org/apache/mina/sm/context/DefaultStateContext.java?rev=586063&r1=586062&r2=586063&view=diff
==============================================================================
--- mina/sandbox/niklas/mina-sm/src/main/java/org/apache/mina/sm/context/DefaultStateContext.java (original)
+++ mina/sandbox/niklas/mina-sm/src/main/java/org/apache/mina/sm/context/DefaultStateContext.java Thu Oct 18 11:39:46 2007
@@ -1,19 +1,20 @@
/*
- * @(#) $Id$
- *
- * Copyright 2004 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*
*/
package org.apache.mina.sm.context;
@@ -21,7 +22,7 @@
/**
*
*
- * @author The Apache Directory Project (mina-dev@directory.apache.org)
+ * @author The Apache MINA Project (dev@mina.apache.org)
* @version $Rev$, $Date$
*/
public class DefaultStateContext extends AbstractStateContext {
Modified: mina/sandbox/niklas/mina-sm/src/main/java/org/apache/mina/sm/context/DefaultStateContextFactory.java
URL: http://svn.apache.org/viewvc/mina/sandbox/niklas/mina-sm/src/main/java/org/apache/mina/sm/context/DefaultStateContextFactory.java?rev=586063&r1=586062&r2=586063&view=diff
==============================================================================
--- mina/sandbox/niklas/mina-sm/src/main/java/org/apache/mina/sm/context/DefaultStateContextFactory.java (original)
+++ mina/sandbox/niklas/mina-sm/src/main/java/org/apache/mina/sm/context/DefaultStateContextFactory.java Thu Oct 18 11:39:46 2007
@@ -1,19 +1,20 @@
/*
- * @(#) $Id$
- *
- * Copyright 2004 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*
*/
package org.apache.mina.sm.context;
@@ -21,7 +22,7 @@
/**
*
*
- * @author The Apache Directory Project (mina-dev@directory.apache.org)
+ * @author The Apache MINA Project (dev@mina.apache.org)
* @version $Rev$, $Date$
*/
public class DefaultStateContextFactory implements StateContextFactory {
Modified: mina/sandbox/niklas/mina-sm/src/main/java/org/apache/mina/sm/context/SingletonStateContextLookup.java
URL: http://svn.apache.org/viewvc/mina/sandbox/niklas/mina-sm/src/main/java/org/apache/mina/sm/context/SingletonStateContextLookup.java?rev=586063&r1=586062&r2=586063&view=diff
==============================================================================
--- mina/sandbox/niklas/mina-sm/src/main/java/org/apache/mina/sm/context/SingletonStateContextLookup.java (original)
+++ mina/sandbox/niklas/mina-sm/src/main/java/org/apache/mina/sm/context/SingletonStateContextLookup.java Thu Oct 18 11:39:46 2007
@@ -1,19 +1,20 @@
/*
- * @(#) $Id$
- *
- * Copyright 2004 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*
*/
package org.apache.mina.sm.context;
@@ -22,7 +23,7 @@
* {@link StateContextLookup} implementation which always returns the same
* {@link StateContext} instance.
*
- * @author The Apache Directory Project (mina-dev@directory.apache.org)
+ * @author The Apache MINA Project (dev@mina.apache.org)
* @version $Rev$, $Date$
*/
public class SingletonStateContextLookup implements StateContextLookup {
Modified: mina/sandbox/niklas/mina-sm/src/main/java/org/apache/mina/sm/context/StateContext.java
URL: http://svn.apache.org/viewvc/mina/sandbox/niklas/mina-sm/src/main/java/org/apache/mina/sm/context/StateContext.java?rev=586063&r1=586062&r2=586063&view=diff
==============================================================================
--- mina/sandbox/niklas/mina-sm/src/main/java/org/apache/mina/sm/context/StateContext.java (original)
+++ mina/sandbox/niklas/mina-sm/src/main/java/org/apache/mina/sm/context/StateContext.java Thu Oct 18 11:39:46 2007
@@ -1,19 +1,20 @@
/*
- * @(#) $Id$
- *
- * Copyright 2004 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*
*/
package org.apache.mina.sm.context;
@@ -23,7 +24,7 @@
/**
*
*
- * @author The Apache Directory Project (mina-dev@directory.apache.org)
+ * @author The Apache MINA Project (dev@mina.apache.org)
* @version $Rev$, $Date$
*/
public interface StateContext {
Modified: mina/sandbox/niklas/mina-sm/src/main/java/org/apache/mina/sm/context/StateContextFactory.java
URL: http://svn.apache.org/viewvc/mina/sandbox/niklas/mina-sm/src/main/java/org/apache/mina/sm/context/StateContextFactory.java?rev=586063&r1=586062&r2=586063&view=diff
==============================================================================
--- mina/sandbox/niklas/mina-sm/src/main/java/org/apache/mina/sm/context/StateContextFactory.java (original)
+++ mina/sandbox/niklas/mina-sm/src/main/java/org/apache/mina/sm/context/StateContextFactory.java Thu Oct 18 11:39:46 2007
@@ -1,19 +1,20 @@
/*
- * @(#) $Id$
- *
- * Copyright 2004 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*
*/
package org.apache.mina.sm.context;
@@ -21,7 +22,7 @@
/**
* Factory which creates {@link StateContext} instances.
*
- * @author The Apache Directory Project (mina-dev@directory.apache.org)
+ * @author The Apache MINA Project (dev@mina.apache.org)
* @version $Rev$, $Date$
*/
public interface StateContextFactory {
Modified: mina/sandbox/niklas/mina-sm/src/main/java/org/apache/mina/sm/context/StateContextLookup.java
URL: http://svn.apache.org/viewvc/mina/sandbox/niklas/mina-sm/src/main/java/org/apache/mina/sm/context/StateContextLookup.java?rev=586063&r1=586062&r2=586063&view=diff
==============================================================================
--- mina/sandbox/niklas/mina-sm/src/main/java/org/apache/mina/sm/context/StateContextLookup.java (original)
+++ mina/sandbox/niklas/mina-sm/src/main/java/org/apache/mina/sm/context/StateContextLookup.java Thu Oct 18 11:39:46 2007
@@ -1,19 +1,20 @@
/*
- * @(#) $Id$
- *
- * Copyright 2004 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*
*/
package org.apache.mina.sm.context;
@@ -21,7 +22,7 @@
/**
* Lookups a {@link StateContext} from a collection of event arguments.
*
- * @author The Apache Directory Project (mina-dev@directory.apache.org)
+ * @author The Apache MINA Project (dev@mina.apache.org)
* @version $Rev$, $Date$
*/
public interface StateContextLookup {
Modified: mina/sandbox/niklas/mina-sm/src/main/java/org/apache/mina/sm/event/DefaultEventFactory.java
URL: http://svn.apache.org/viewvc/mina/sandbox/niklas/mina-sm/src/main/java/org/apache/mina/sm/event/DefaultEventFactory.java?rev=586063&r1=586062&r2=586063&view=diff
==============================================================================
--- mina/sandbox/niklas/mina-sm/src/main/java/org/apache/mina/sm/event/DefaultEventFactory.java (original)
+++ mina/sandbox/niklas/mina-sm/src/main/java/org/apache/mina/sm/event/DefaultEventFactory.java Thu Oct 18 11:39:46 2007
@@ -1,19 +1,20 @@
/*
- * @(#) $Id$
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * Copyright 2006 The Apache Software Foundation
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*
*/
package org.apache.mina.sm.event;
@@ -26,15 +27,13 @@
* Default {@link EventFactory} implementation. Uses the method's name as
* event id.
*
- * @author The Apache Directory Project (mina-dev@directory.apache.org)
+ * @author The Apache MINA Project (dev@mina.apache.org)
* @version $Rev$, $Date$
*/
-public class DefaultEventFactory implements EventFactory
-{
+public class DefaultEventFactory implements EventFactory {
- public Event create( StateContext context, Method method, Object[] arguments )
- {
- return new Event( method.getName(), context, arguments );
+ public Event create(StateContext context, Method method, Object[] arguments) {
+ return new Event(method.getName(), context, arguments);
}
}
Modified: mina/sandbox/niklas/mina-sm/src/main/java/org/apache/mina/sm/event/Event.java
URL: http://svn.apache.org/viewvc/mina/sandbox/niklas/mina-sm/src/main/java/org/apache/mina/sm/event/Event.java?rev=586063&r1=586062&r2=586063&view=diff
==============================================================================
--- mina/sandbox/niklas/mina-sm/src/main/java/org/apache/mina/sm/event/Event.java (original)
+++ mina/sandbox/niklas/mina-sm/src/main/java/org/apache/mina/sm/event/Event.java Thu Oct 18 11:39:46 2007
@@ -1,19 +1,20 @@
/*
- * @(#) $Id$
- *
- * Copyright 2004 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*
*/
package org.apache.mina.sm.event;
@@ -25,23 +26,21 @@
/**
*
*
- * @author The Apache Directory Project (mina-dev@directory.apache.org)
+ * @author The Apache MINA Project (dev@mina.apache.org)
* @version $Rev$, $Date$
*/
-public class Event
-{
+public class Event {
public static final String WILDCARD_EVENT_ID = "*";
private final Object id;
private final StateContext context;
private final Object[] arguments;
- public Event( Object id, StateContext context )
- {
- this( id, context, new Object[0] );
+ public Event(Object id, StateContext context) {
+ this(id, context, new Object[0]);
}
- public Event( Object id, StateContext context, Object[] arguments )
- {
+
+ public Event(Object id, StateContext context, Object[] arguments) {
if (id == null) {
throw new NullPointerException("id");
}
@@ -56,27 +55,23 @@
this.arguments = arguments;
}
- public StateContext getContext()
- {
+ public StateContext getContext() {
return context;
}
- public Object getId()
- {
+ public Object getId() {
return id;
}
-
- public Object[] getArguments()
- {
+
+ public Object[] getArguments() {
return arguments;
}
- public String toString()
- {
- return new ToStringBuilder( this )
- .append( "id", id )
- .append( "context", context )
- .append( "arguments", arguments )
+ public String toString() {
+ return new ToStringBuilder(this)
+ .append("id", id)
+ .append("context", context)
+ .append("arguments", arguments)
.toString();
}
}
Modified: mina/sandbox/niklas/mina-sm/src/main/java/org/apache/mina/sm/event/EventArgumentsInterceptor.java
URL: http://svn.apache.org/viewvc/mina/sandbox/niklas/mina-sm/src/main/java/org/apache/mina/sm/event/EventArgumentsInterceptor.java?rev=586063&r1=586062&r2=586063&view=diff
==============================================================================
--- mina/sandbox/niklas/mina-sm/src/main/java/org/apache/mina/sm/event/EventArgumentsInterceptor.java (original)
+++ mina/sandbox/niklas/mina-sm/src/main/java/org/apache/mina/sm/event/EventArgumentsInterceptor.java Thu Oct 18 11:39:46 2007
@@ -1,19 +1,20 @@
/*
- * @(#) $Id$
- *
- * Copyright 2004 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*
*/
package org.apache.mina.sm.event;
@@ -21,7 +22,7 @@
/**
*
*
- * @author The Apache Directory Project (mina-dev@directory.apache.org)
+ * @author The Apache MINA Project (dev@mina.apache.org)
* @version $Rev$, $Date$
*/
public interface EventArgumentsInterceptor {
Modified: mina/sandbox/niklas/mina-sm/src/main/java/org/apache/mina/sm/event/EventFactory.java
URL: http://svn.apache.org/viewvc/mina/sandbox/niklas/mina-sm/src/main/java/org/apache/mina/sm/event/EventFactory.java?rev=586063&r1=586062&r2=586063&view=diff
==============================================================================
--- mina/sandbox/niklas/mina-sm/src/main/java/org/apache/mina/sm/event/EventFactory.java (original)
+++ mina/sandbox/niklas/mina-sm/src/main/java/org/apache/mina/sm/event/EventFactory.java Thu Oct 18 11:39:46 2007
@@ -1,19 +1,20 @@
/*
- * @(#) $Id$
- *
- * Copyright 2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*
*/
package org.apache.mina.sm.event;
@@ -27,7 +28,7 @@
* Used by {@link StateMachineProxyFactory} to create {@link Event} objects when
* methods are invoked on the proxy.
*
- * @author The Apache Directory Project (mina-dev@directory.apache.org)
+ * @author The Apache MINA Project (dev@mina.apache.org)
* @version $Rev$, $Date$
*/
public interface EventFactory
@@ -41,5 +42,5 @@
* @param args the method arguments.
* @return the {@link Event} object.
*/
- Event create( StateContext context, Method method, Object[] arguments );
+ Event create(StateContext context, Method method, Object[] arguments);
}
Modified: mina/sandbox/niklas/mina-sm/src/main/java/org/apache/mina/sm/event/UnhandledEventException.java
URL: http://svn.apache.org/viewvc/mina/sandbox/niklas/mina-sm/src/main/java/org/apache/mina/sm/event/UnhandledEventException.java?rev=586063&r1=586062&r2=586063&view=diff
==============================================================================
--- mina/sandbox/niklas/mina-sm/src/main/java/org/apache/mina/sm/event/UnhandledEventException.java (original)
+++ mina/sandbox/niklas/mina-sm/src/main/java/org/apache/mina/sm/event/UnhandledEventException.java Thu Oct 18 11:39:46 2007
@@ -1,19 +1,20 @@
/*
- * @(#) $Id$
- *
- * Copyright 2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*
*/
package org.apache.mina.sm.event;
@@ -21,30 +22,23 @@
/**
* Thrown when an {@link Event} passed to a state machine couldn't be handled.
*
- * @author The Apache Directory Project (mina-dev@directory.apache.org)
+ * @author The Apache MINA Project (dev@mina.apache.org)
* @version $Rev$, $Date$
*/
-public class UnhandledEventException extends RuntimeException
-{
+public class UnhandledEventException extends RuntimeException {
+ private final Event event;
- public UnhandledEventException()
- {
- super();
+ public UnhandledEventException(Event event) {
+ super("Unhandled event: " + event);
+ this.event = event;
}
- public UnhandledEventException( String message, Throwable cause )
- {
- super(message, cause);
+ /**
+ * Returns the {@link Event} which couldn't be handled.
+ *
+ * @return the {@link Event}.
+ */
+ public Event getEvent() {
+ return event;
}
-
- public UnhandledEventException( String message )
- {
- super(message);
- }
-
- public UnhandledEventException( Throwable cause )
- {
- super(cause);
- }
-
}
Modified: mina/sandbox/niklas/mina-sm/src/main/java/org/apache/mina/sm/mina/Events.java
URL: http://svn.apache.org/viewvc/mina/sandbox/niklas/mina-sm/src/main/java/org/apache/mina/sm/mina/Events.java?rev=586063&r1=586062&r2=586063&view=diff
==============================================================================
--- mina/sandbox/niklas/mina-sm/src/main/java/org/apache/mina/sm/mina/Events.java (original)
+++ mina/sandbox/niklas/mina-sm/src/main/java/org/apache/mina/sm/mina/Events.java Thu Oct 18 11:39:46 2007
@@ -1,19 +1,20 @@
/*
- * @(#) $Id$
- *
- * Copyright 2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*
*/
package org.apache.mina.sm.mina;
@@ -23,20 +24,24 @@
/**
* Defines all possible MINA {@link IoHandler} events.
*
- * @author The Apache Directory Project (mina-dev@directory.apache.org)
+ * @author The Apache MINA Project (dev@mina.apache.org)
* @version $Rev$, $Date$
*/
-public final class Events
-{
+public final class Events {
public static final String SESSION_CREATED = "sessionCreated";
+
public static final String SESSION_OPENED = "sessionOpened";
+
public static final String SESSION_CLOSED = "sessionClosed";
+
public static final String SESSION_IDLE = "sessionIdle";
+
public static final String MESSAGE_RECEIVED = "messageReceived";
+
public static final String MESSAGE_SENT = "messageSent";
+
public static final String EXCEPTION_CAUGHT = "exceptionCaught";
-
- private Events()
- {
+
+ private Events() {
}
}
Modified: mina/sandbox/niklas/mina-sm/src/main/java/org/apache/mina/sm/mina/MinaStateContextLookup.java
URL: http://svn.apache.org/viewvc/mina/sandbox/niklas/mina-sm/src/main/java/org/apache/mina/sm/mina/MinaStateContextLookup.java?rev=586063&r1=586062&r2=586063&view=diff
==============================================================================
--- mina/sandbox/niklas/mina-sm/src/main/java/org/apache/mina/sm/mina/MinaStateContextLookup.java (original)
+++ mina/sandbox/niklas/mina-sm/src/main/java/org/apache/mina/sm/mina/MinaStateContextLookup.java Thu Oct 18 11:39:46 2007
@@ -1,19 +1,20 @@
/*
- * @(#) $Id$
- *
- * Copyright 2004 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*
*/
package org.apache.mina.sm.mina;
@@ -27,7 +28,7 @@
/**
*
*
- * @author The Apache Directory Project (mina-dev@directory.apache.org)
+ * @author The Apache MINA Project (dev@mina.apache.org)
* @version $Rev$, $Date$
*/
public class MinaStateContextLookup extends AbstractStateContextLookup {
Modified: mina/sandbox/niklas/mina-sm/src/main/java/org/apache/mina/sm/transition/AbstractTransition.java
URL: http://svn.apache.org/viewvc/mina/sandbox/niklas/mina-sm/src/main/java/org/apache/mina/sm/transition/AbstractTransition.java?rev=586063&r1=586062&r2=586063&view=diff
==============================================================================
--- mina/sandbox/niklas/mina-sm/src/main/java/org/apache/mina/sm/transition/AbstractTransition.java (original)
+++ mina/sandbox/niklas/mina-sm/src/main/java/org/apache/mina/sm/transition/AbstractTransition.java Thu Oct 18 11:39:46 2007
@@ -1,19 +1,20 @@
/*
- * @(#) $Id$
- *
- * Copyright 2004 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*
*/
package org.apache.mina.sm.transition;
@@ -27,78 +28,63 @@
/**
*
*
- * @author The Apache Directory Project (mina-dev@directory.apache.org)
+ * @author The Apache MINA Project (dev@mina.apache.org)
* @version $Rev$, $Date$
*/
-public abstract class AbstractTransition implements Transition
-{
- private final Object eventId;
+public abstract class AbstractTransition implements Transition {
+ private final Object eventId;
+
private final State nextState;
- public AbstractTransition( Object eventId )
- {
- this( eventId, null );
+ public AbstractTransition(Object eventId) {
+ this(eventId, null);
}
- public AbstractTransition( Object eventId, State nextState )
- {
+ public AbstractTransition(Object eventId, State nextState) {
this.eventId = eventId;
this.nextState = nextState;
}
-
- public Object getEventId()
- {
+
+ public Object getEventId() {
return eventId;
}
- public State getNextState()
- {
+ public State getNextState() {
return nextState;
}
- public boolean execute( Event event )
- {
- if( !eventId.equals( Event.WILDCARD_EVENT_ID )
- && !eventId.equals( event.getId() ) )
- {
+ public boolean execute(Event event) {
+ if (!eventId.equals(Event.WILDCARD_EVENT_ID) && !eventId.equals(event.getId())) {
return false;
}
- return doExecute( event );
+ return doExecute(event);
}
protected abstract boolean doExecute(Event event);
-
- public boolean equals( Object o )
- {
- if( ! ( o instanceof AbstractTransition ) )
- {
+
+ public boolean equals(Object o) {
+ if (!(o instanceof AbstractTransition)) {
return false;
}
- if ( o == this )
- {
+ if (o == this) {
return true;
}
- AbstractTransition that = ( AbstractTransition ) o;
+ AbstractTransition that = (AbstractTransition) o;
return new EqualsBuilder()
- .append( eventId, that.eventId )
- .append( nextState, that.nextState )
+ .append(eventId, that.eventId)
+ .append(nextState, that.nextState)
.isEquals();
}
-
- public int hashCode()
- {
- return new HashCodeBuilder( 11, 31 )
- .append( eventId )
- .append( nextState )
- .toHashCode();
- }
-
- public String toString()
- {
- return new ToStringBuilder( this )
- .append( "eventId", eventId )
- .append( "nextState", nextState )
- .toString();
+
+ public int hashCode() {
+ return new HashCodeBuilder(11, 31).append(eventId).append(nextState).toHashCode();
+ }
+
+ public String toString() {
+ return new ToStringBuilder(this)
+ .append("eventId", eventId)
+ .append("nextState", nextState)
+ .toString();
}
}
Modified: mina/sandbox/niklas/mina-sm/src/main/java/org/apache/mina/sm/transition/AmbiguousMethodException.java
URL: http://svn.apache.org/viewvc/mina/sandbox/niklas/mina-sm/src/main/java/org/apache/mina/sm/transition/AmbiguousMethodException.java?rev=586063&r1=586062&r2=586063&view=diff
==============================================================================
--- mina/sandbox/niklas/mina-sm/src/main/java/org/apache/mina/sm/transition/AmbiguousMethodException.java (original)
+++ mina/sandbox/niklas/mina-sm/src/main/java/org/apache/mina/sm/transition/AmbiguousMethodException.java Thu Oct 18 11:39:46 2007
@@ -1,19 +1,20 @@
/*
- * @(#) $Id$
- *
- * Copyright 2004 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*
*/
package org.apache.mina.sm.transition;
@@ -21,42 +22,13 @@
/**
*
*
- * @author The Apache Directory Project (mina-dev@directory.apache.org)
+ * @author The Apache MINA Project (dev@mina.apache.org)
* @version $Rev$, $Date$
*/
public class AmbiguousMethodException extends RuntimeException {
- /**
- *
- */
- public AmbiguousMethodException() {
- super();
- // TODO Auto-generated constructor stub
- }
-
- /**
- * @param message
- */
- public AmbiguousMethodException(String message) {
- super(message);
- // TODO Auto-generated constructor stub
+ public AmbiguousMethodException(String methodName) {
+ super(methodName);
}
-
- /**
- * @param message
- * @param cause
- */
- public AmbiguousMethodException(String message, Throwable cause) {
- super(message, cause);
- // TODO Auto-generated constructor stub
- }
-
- /**
- * @param cause
- */
- public AmbiguousMethodException(Throwable cause) {
- super(cause);
- // TODO Auto-generated constructor stub
- }
-
+
}
Modified: mina/sandbox/niklas/mina-sm/src/main/java/org/apache/mina/sm/transition/MethodInvocationException.java
URL: http://svn.apache.org/viewvc/mina/sandbox/niklas/mina-sm/src/main/java/org/apache/mina/sm/transition/MethodInvocationException.java?rev=586063&r1=586062&r2=586063&view=diff
==============================================================================
--- mina/sandbox/niklas/mina-sm/src/main/java/org/apache/mina/sm/transition/MethodInvocationException.java (original)
+++ mina/sandbox/niklas/mina-sm/src/main/java/org/apache/mina/sm/transition/MethodInvocationException.java Thu Oct 18 11:39:46 2007
@@ -1,62 +1,36 @@
/*
- * @(#) $Id$
- *
- * Copyright 2004 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*
*/
package org.apache.mina.sm.transition;
+import java.lang.reflect.Method;
+
/**
*
*
- * @author The Apache Directory Project (mina-dev@directory.apache.org)
+ * @author The Apache MINA Project (dev@mina.apache.org)
* @version $Rev$, $Date$
*/
public class MethodInvocationException extends RuntimeException {
- /**
- *
- */
- public MethodInvocationException() {
- super();
- // TODO Auto-generated constructor stub
- }
-
- /**
- * @param message
- */
- public MethodInvocationException(String message) {
- super(message);
- // TODO Auto-generated constructor stub
- }
-
- /**
- * @param message
- * @param cause
- */
- public MethodInvocationException(String message, Throwable cause) {
- super(message, cause);
- // TODO Auto-generated constructor stub
- }
-
- /**
- * @param cause
- */
- public MethodInvocationException(Throwable cause) {
- super(cause);
- // TODO Auto-generated constructor stub
+ public MethodInvocationException(Method method, Throwable cause) {
+ super("Invoking method: " + method, cause);
}
}
Modified: mina/sandbox/niklas/mina-sm/src/main/java/org/apache/mina/sm/transition/MethodTransition.java
URL: http://svn.apache.org/viewvc/mina/sandbox/niklas/mina-sm/src/main/java/org/apache/mina/sm/transition/MethodTransition.java?rev=586063&r1=586062&r2=586063&view=diff
==============================================================================
--- mina/sandbox/niklas/mina-sm/src/main/java/org/apache/mina/sm/transition/MethodTransition.java (original)
+++ mina/sandbox/niklas/mina-sm/src/main/java/org/apache/mina/sm/transition/MethodTransition.java Thu Oct 18 11:39:46 2007
@@ -1,19 +1,20 @@
/*
- * @(#) $Id$
- *
- * Copyright 2004 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*
*/
package org.apache.mina.sm.transition;
@@ -34,7 +35,7 @@
/**
*
*
- * @author The Apache Directory Project (mina-dev@directory.apache.org)
+ * @author The Apache MINA Project (dev@mina.apache.org)
* @version $Rev$, $Date$
*/
public class MethodTransition extends AbstractTransition {
@@ -44,8 +45,7 @@
private final Method method;
private final Object target;
- public MethodTransition(Object eventId, State nextState, Method method,
- Object target) {
+ public MethodTransition(Object eventId, State nextState, Method method, Object target) {
super(eventId, nextState);
this.method = method;
this.target = target;
@@ -67,8 +67,7 @@
this(eventId, null, methodName, target);
}
- public MethodTransition(Object eventId, State nextState, String methodName,
- Object target) {
+ public MethodTransition(Object eventId, State nextState, String methodName, Object target) {
super(eventId, nextState);
this.target = target;
@@ -91,13 +90,11 @@
this.method = result;
}
- public Method getMethod()
- {
+ public Method getMethod() {
return method;
}
- public Object getTarget()
- {
+ public Object getTarget() {
return target;
}
@@ -181,45 +178,36 @@
if (ite.getCause() instanceof RuntimeException) {
throw (RuntimeException) ite.getCause();
}
- throw new MethodInvocationException(ite);
+ throw new MethodInvocationException(method, ite);
} catch (IllegalAccessException iae) {
- throw new MethodInvocationException(iae);
+ throw new MethodInvocationException(method, iae);
}
}
- public boolean equals( Object o )
- {
- if( ! ( o instanceof MethodTransition ) )
- {
+ public boolean equals(Object o) {
+ if (!(o instanceof MethodTransition)) {
return false;
}
- if ( o == this )
- {
+ if (o == this) {
return true;
}
- MethodTransition that = ( MethodTransition ) o;
+ MethodTransition that = (MethodTransition) o;
return new EqualsBuilder()
- .appendSuper( super.equals( that ) )
- .append( method, that.method )
- .append( target, that.target )
+ .appendSuper(super.equals(that))
+ .append(method, that.method)
+ .append(target, that.target)
.isEquals();
}
-
- public int hashCode()
- {
- return new HashCodeBuilder( 13, 33 )
- .appendSuper( super.hashCode() )
- .append( method )
- .append( target )
- .toHashCode();
- }
-
- public String toString()
- {
- return new ToStringBuilder( this )
- .appendSuper( super.toString() )
- .append( "method", method )
- .append( "target", target )
- .toString();
+
+ public int hashCode() {
+ return new HashCodeBuilder(13, 33).appendSuper(super.hashCode()).append(method).append(target).toHashCode();
+ }
+
+ public String toString() {
+ return new ToStringBuilder(this)
+ .appendSuper(super.toString())
+ .append("method", method)
+ .append("target", target)
+ .toString();
}
}
Modified: mina/sandbox/niklas/mina-sm/src/main/java/org/apache/mina/sm/transition/NoSuchMethodException.java
URL: http://svn.apache.org/viewvc/mina/sandbox/niklas/mina-sm/src/main/java/org/apache/mina/sm/transition/NoSuchMethodException.java?rev=586063&r1=586062&r2=586063&view=diff
==============================================================================
--- mina/sandbox/niklas/mina-sm/src/main/java/org/apache/mina/sm/transition/NoSuchMethodException.java (original)
+++ mina/sandbox/niklas/mina-sm/src/main/java/org/apache/mina/sm/transition/NoSuchMethodException.java Thu Oct 18 11:39:46 2007
@@ -1,19 +1,20 @@
/*
- * @(#) $Id$
- *
- * Copyright 2004 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*
*/
package org.apache.mina.sm.transition;
@@ -21,42 +22,13 @@
/**
*
*
- * @author The Apache Directory Project (mina-dev@directory.apache.org)
+ * @author The Apache MINA Project (dev@mina.apache.org)
* @version $Rev$, $Date$
*/
public class NoSuchMethodException extends RuntimeException {
- /**
- *
- */
- public NoSuchMethodException() {
- super();
- // TODO Auto-generated constructor stub
- }
-
- /**
- * @param message
- */
- public NoSuchMethodException(String message) {
- super(message);
- // TODO Auto-generated constructor stub
+ public NoSuchMethodException(String methodName) {
+ super(methodName);
}
-
- /**
- * @param message
- * @param cause
- */
- public NoSuchMethodException(String message, Throwable cause) {
- super(message, cause);
- // TODO Auto-generated constructor stub
- }
-
- /**
- * @param cause
- */
- public NoSuchMethodException(Throwable cause) {
- super(cause);
- // TODO Auto-generated constructor stub
- }
-
+
}
Modified: mina/sandbox/niklas/mina-sm/src/main/java/org/apache/mina/sm/transition/NoopTransition.java
URL: http://svn.apache.org/viewvc/mina/sandbox/niklas/mina-sm/src/main/java/org/apache/mina/sm/transition/NoopTransition.java?rev=586063&r1=586062&r2=586063&view=diff
==============================================================================
--- mina/sandbox/niklas/mina-sm/src/main/java/org/apache/mina/sm/transition/NoopTransition.java (original)
+++ mina/sandbox/niklas/mina-sm/src/main/java/org/apache/mina/sm/transition/NoopTransition.java Thu Oct 18 11:39:46 2007
@@ -1,19 +1,20 @@
/*
- * @(#) $Id$
- *
- * Copyright 2004 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*
*/
package org.apache.mina.sm.transition;
@@ -24,7 +25,7 @@
/**
* {@link Transition} implementation which does nothing but change the state.
*
- * @author The Apache Directory Project (mina-dev@directory.apache.org)
+ * @author The Apache MINA Project (dev@mina.apache.org)
* @version $Rev$, $Date$
*/
public class NoopTransition extends AbstractTransition {
Modified: mina/sandbox/niklas/mina-sm/src/main/java/org/apache/mina/sm/transition/Transition.java
URL: http://svn.apache.org/viewvc/mina/sandbox/niklas/mina-sm/src/main/java/org/apache/mina/sm/transition/Transition.java?rev=586063&r1=586062&r2=586063&view=diff
==============================================================================
--- mina/sandbox/niklas/mina-sm/src/main/java/org/apache/mina/sm/transition/Transition.java (original)
+++ mina/sandbox/niklas/mina-sm/src/main/java/org/apache/mina/sm/transition/Transition.java Thu Oct 18 11:39:46 2007
@@ -1,19 +1,20 @@
/*
- * @(#) $Id$
- *
- * Copyright 2004 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*
*/
package org.apache.mina.sm.transition;
@@ -24,7 +25,7 @@
/**
*
*
- * @author The Apache Directory Project (mina-dev@directory.apache.org)
+ * @author The Apache MINA Project (dev@mina.apache.org)
* @version $Rev$, $Date$
*/
public interface Transition {
Modified: mina/sandbox/niklas/mina-sm/src/test/java/org/apache/mina/sm/StateMachineFactoryTest.java
URL: http://svn.apache.org/viewvc/mina/sandbox/niklas/mina-sm/src/test/java/org/apache/mina/sm/StateMachineFactoryTest.java?rev=586063&r1=586062&r2=586063&view=diff
==============================================================================
--- mina/sandbox/niklas/mina-sm/src/test/java/org/apache/mina/sm/StateMachineFactoryTest.java (original)
+++ mina/sandbox/niklas/mina-sm/src/test/java/org/apache/mina/sm/StateMachineFactoryTest.java Thu Oct 18 11:39:46 2007
@@ -1,19 +1,20 @@
/*
- * @(#) $Id$
- *
- * Copyright 2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*
*/
package org.apache.mina.sm;
@@ -34,140 +35,131 @@
/**
* Tests {@link StateMachineFactory}.
*
- * @author The Apache Directory Project (mina-dev@directory.apache.org)
+ * @author The Apache MINA Project (dev@mina.apache.org)
* @version $Rev$, $Date$
*/
-public class StateMachineFactoryTest extends TestCase
-{
+public class StateMachineFactoryTest extends TestCase {
Method barInA;
Method error;
Method fooInA;
Method fooInB;
Method barInC;
Method fooOrBarInCOrFooInD;
-
- protected void setUp() throws Exception
- {
- barInA = States.class.getDeclaredMethod( "barInA", new Class[ 0 ] );
- error = States.class.getDeclaredMethod( "error", new Class[ 0 ] );
- fooInA = States.class.getDeclaredMethod( "fooInA", new Class[ 0 ] );
- fooInB = States.class.getDeclaredMethod( "fooInB", new Class[ 0 ] );
- barInC = States.class.getDeclaredMethod( "barInC", new Class[ 0 ] );
- fooOrBarInCOrFooInD = States.class.getDeclaredMethod( "fooOrBarInCOrFooInD", new Class[ 0 ] );
+
+ protected void setUp() throws Exception {
+ barInA = States.class.getDeclaredMethod("barInA", new Class[0]);
+ error = States.class.getDeclaredMethod("error", new Class[0]);
+ fooInA = States.class.getDeclaredMethod("fooInA", new Class[0]);
+ fooInB = States.class.getDeclaredMethod("fooInB", new Class[0]);
+ barInC = States.class.getDeclaredMethod("barInC", new Class[0]);
+ fooOrBarInCOrFooInD = States.class.getDeclaredMethod("fooOrBarInCOrFooInD", new Class[0]);
}
- public void testCreate() throws Exception
- {
+ public void testCreate() throws Exception {
States states = new States();
- StateMachine sm = StateMachineFactory.create( States.A, states );
-
- State a = sm.getState( States.A );
- State b = sm.getState( States.B );
- State c = sm.getState( States.C );
- State d = sm.getState( States.D );
-
- assertEquals( States.A, a.getId() );
- assertNull( a.getParent() );
- assertEquals( States.B, b.getId() );
- assertSame( a, b.getParent() );
- assertEquals( States.C, c.getId() );
- assertSame( b, c.getParent() );
- assertEquals( States.D, d.getId() );
- assertSame( a, d.getParent() );
-
+ StateMachine sm = StateMachineFactory.create(States.A, states);
+
+ State a = sm.getState(States.A);
+ State b = sm.getState(States.B);
+ State c = sm.getState(States.C);
+ State d = sm.getState(States.D);
+
+ assertEquals(States.A, a.getId());
+ assertNull(a.getParent());
+ assertEquals(States.B, b.getId());
+ assertSame(a, b.getParent());
+ assertEquals(States.C, c.getId());
+ assertSame(b, c.getParent());
+ assertEquals(States.D, d.getId());
+ assertSame(a, d.getParent());
+
List<Transition> trans = null;
-
+
trans = a.getTransitions();
- assertEquals( 3, trans.size() );
- assertEquals( new MethodTransition( "bar", barInA, states ), trans.get( 0 ) );
- assertEquals( new MethodTransition( "*", error, states ), trans.get( 1 ) );
- assertEquals( new MethodTransition( "foo", b, fooInA, states ), trans.get( 2 ) );
+ assertEquals(3, trans.size());
+ assertEquals(new MethodTransition("bar", barInA, states), trans.get(0));
+ assertEquals(new MethodTransition("*", error, states), trans.get(1));
+ assertEquals(new MethodTransition("foo", b, fooInA, states), trans.get(2));
trans = b.getTransitions();
- assertEquals( 1, trans.size() );
- assertEquals( new MethodTransition( "foo", c, fooInB, states ), trans.get( 0 ) );
-
+ assertEquals(1, trans.size());
+ assertEquals(new MethodTransition("foo", c, fooInB, states), trans.get(0));
+
trans = c.getTransitions();
- assertEquals( 3, trans.size() );
- assertEquals( new MethodTransition( "bar", a, barInC, states ), trans.get( 0 ) );
- assertEquals( new MethodTransition( "foo", d, fooOrBarInCOrFooInD, states ), trans.get( 1 ) );
- assertEquals( new MethodTransition( "bar", d, fooOrBarInCOrFooInD, states ), trans.get( 2 ) );
+ assertEquals(3, trans.size());
+ assertEquals(new MethodTransition("bar", a, barInC, states), trans.get(0));
+ assertEquals(new MethodTransition("foo", d, fooOrBarInCOrFooInD, states), trans.get(1));
+ assertEquals(new MethodTransition("bar", d, fooOrBarInCOrFooInD, states), trans.get(2));
trans = d.getTransitions();
- assertEquals( 1, trans.size() );
- assertEquals( new MethodTransition( "foo", fooOrBarInCOrFooInD, states ), trans.get( 0 ) );
+ assertEquals(1, trans.size());
+ assertEquals(new MethodTransition("foo", fooOrBarInCOrFooInD, states), trans.get(0));
}
- public void testCreateStates() throws Exception
- {
- State[] states = StateMachineFactory.createStates( StateMachineFactory.getFields( States.class ) );
- assertEquals( States.A, states[ 0 ].getId() );
- assertNull( states[ 0 ].getParent() );
- assertEquals( States.B, states[ 1 ].getId() );
- assertEquals( states[ 0 ], states[ 1 ].getParent() );
- assertEquals( States.C, states[ 2 ].getId() );
- assertEquals( states[ 1 ], states[ 2 ].getParent() );
- assertEquals( States.D, states[ 3 ].getId() );
- assertEquals( states[ 0 ], states[ 3 ].getParent() );
+ public void testCreateStates() throws Exception {
+ State[] states = StateMachineFactory.createStates(StateMachineFactory.getFields(States.class));
+ assertEquals(States.A, states[0].getId());
+ assertNull(states[0].getParent());
+ assertEquals(States.B, states[1].getId());
+ assertEquals(states[0], states[1].getParent());
+ assertEquals(States.C, states[2].getId());
+ assertEquals(states[1], states[2].getParent());
+ assertEquals(States.D, states[3].getId());
+ assertEquals(states[0], states[3].getParent());
}
- public void testCreateStatesMissingParents() throws Exception
- {
- try
- {
- StateMachineFactory.createStates( StateMachineFactory.getFields( StatesWithMissingParents.class ) );
- fail( "Missing parents. FsmCreationException expected." );
- }
- catch( StateMachineCreationException fce )
- {
+ public void testCreateStatesMissingParents() throws Exception {
+ try {
+ StateMachineFactory.createStates(StateMachineFactory.getFields(StatesWithMissingParents.class));
+ fail("Missing parents. FsmCreationException expected.");
+ } catch (StateMachineCreationException fce) {
}
}
- public static class States
- {
- @org.apache.mina.sm.annotation.State protected static final String A = "a";
- @org.apache.mina.sm.annotation.State( A ) protected static final String B = "b";
- @org.apache.mina.sm.annotation.State( B ) protected static final String C = "c";
- @org.apache.mina.sm.annotation.State( A ) protected static final String D = "d";
+ public static class States {
+ @org.apache.mina.sm.annotation.State
+ protected static final String A = "a";
+ @org.apache.mina.sm.annotation.State(A)
+ protected static final String B = "b";
+ @org.apache.mina.sm.annotation.State(B)
+ protected static final String C = "c";
+ @org.apache.mina.sm.annotation.State(A)
+ protected static final String D = "d";
- @Handler( on = "bar", in = A )
- protected void barInA()
- {
+ @Handler(on = "bar", in = A)
+ protected void barInA() {
}
-
- @Handler( on = "bar", in = C, next = A )
- protected void barInC()
- {
+
+ @Handler(on = "bar", in = C, next = A)
+ protected void barInC() {
}
-
- @Handler( in = A )
- protected void error()
- {
+
+ @Handler(in = A)
+ protected void error() {
}
-
- @Handler( on = "foo", in = A, next = B )
- protected void fooInA()
- {
+
+ @Handler(on = "foo", in = A, next = B)
+ protected void fooInA() {
}
-
- @Handler( on = "foo", in = B, next = C )
- protected void fooInB()
- {
+
+ @Handler(on = "foo", in = B, next = C)
+ protected void fooInB() {
}
-
- @Handlers( { @Handler( on = { "foo", "bar" }, in = C, next = D ),
- @Handler( on = "foo", in = D ) } )
- protected void fooOrBarInCOrFooInD()
- {
+
+ @Handlers( { @Handler(on = { "foo", "bar" }, in = C, next = D), @Handler(on = "foo", in = D) })
+ protected void fooOrBarInCOrFooInD() {
}
}
- public static class StatesWithMissingParents
- {
- @org.apache.mina.sm.annotation.State( "b" ) public static final String A = "a";
- @org.apache.mina.sm.annotation.State( "c" ) public static final String B = "b";
- @org.apache.mina.sm.annotation.State( "d" ) public static final String C = "c";
- @org.apache.mina.sm.annotation.State( "e" ) public static final String D = "d";
+ public static class StatesWithMissingParents {
+ @org.apache.mina.sm.annotation.State("b")
+ public static final String A = "a";
+ @org.apache.mina.sm.annotation.State("c")
+ public static final String B = "b";
+ @org.apache.mina.sm.annotation.State("d")
+ public static final String C = "c";
+ @org.apache.mina.sm.annotation.State("e")
+ public static final String D = "d";
}
}
Modified: mina/sandbox/niklas/mina-sm/src/test/java/org/apache/mina/sm/StateMachineProxyFactoryTest.java
URL: http://svn.apache.org/viewvc/mina/sandbox/niklas/mina-sm/src/test/java/org/apache/mina/sm/StateMachineProxyFactoryTest.java?rev=586063&r1=586062&r2=586063&view=diff
==============================================================================
--- mina/sandbox/niklas/mina-sm/src/test/java/org/apache/mina/sm/StateMachineProxyFactoryTest.java (original)
+++ mina/sandbox/niklas/mina-sm/src/test/java/org/apache/mina/sm/StateMachineProxyFactoryTest.java Thu Oct 18 11:39:46 2007
@@ -1,19 +1,20 @@
/*
- * @(#) $Id$
- *
- * Copyright 2004 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*
*/
package org.apache.mina.sm;
@@ -30,122 +31,116 @@
/**
* Tests {@link StateMachineProxyFactory}.
*
- * @author The Apache Directory Project (mina-dev@directory.apache.org)
+ * @author The Apache MINA Project (dev@mina.apache.org)
* @version $Rev$, $Date$
*/
-public class StateMachineProxyFactoryTest extends TestCase
-{
+public class StateMachineProxyFactoryTest extends TestCase {
- public void testReentrantStateMachine() throws Exception
- {
+ public void testReentrantStateMachine() throws Exception {
ReentrantStateMachineHandler handler = new ReentrantStateMachineHandler();
-
- State s1 = new State( "s1" );
- State s2 = new State( "s2" );
- State s3 = new State( "s3" );
-
- s1.addTransition( new MethodTransition( "call1", s2, handler ) );
- s2.addTransition( new MethodTransition( "call2", s3, handler ) );
- s3.addTransition( new MethodTransition( "call3", handler ) );
-
- StateMachine sm = new StateMachine( new State[] { s1, s2, s3 }, "s1" );
- Reentrant reentrant = ( Reentrant ) StateMachineProxyFactory.create( Reentrant.class, sm );
- reentrant.call1( reentrant );
- assertTrue( handler.finished );
+
+ State s1 = new State("s1");
+ State s2 = new State("s2");
+ State s3 = new State("s3");
+
+ s1.addTransition(new MethodTransition("call1", s2, handler));
+ s2.addTransition(new MethodTransition("call2", s3, handler));
+ s3.addTransition(new MethodTransition("call3", handler));
+
+ StateMachine sm = new StateMachine(new State[] { s1, s2, s3 }, "s1");
+ Reentrant reentrant = (Reentrant) StateMachineProxyFactory.create(Reentrant.class, sm);
+ reentrant.call1(reentrant);
+ assertTrue(handler.finished);
}
- public void testTapeDeckStateMachine() throws Exception
- {
+ public void testTapeDeckStateMachine() throws Exception {
TapeDeckStateMachineHandler handler = new TapeDeckStateMachineHandler();
-
- State parent = new State( "parent" );
- State s1 = new State( "s1", parent );
- State s2 = new State( "s2", parent );
- State s3 = new State( "s3", parent );
- State s4 = new State( "s4", parent );
- State s5 = new State( "s5", parent );
-
- parent.addTransition( new MethodTransition( "*", "error", handler ) );
- s1.addTransition( new MethodTransition( "insert", s2, "inserted", handler ) );
- s2.addTransition( new MethodTransition( "start", s3, "playing", handler ) );
- s3.addTransition( new MethodTransition( "stop", s4, "stopped", handler ) );
- s3.addTransition( new MethodTransition( "pause", s5, "paused", handler ) );
- s4.addTransition( new MethodTransition( "eject", s1, "ejected", handler ) );
- s5.addTransition( new MethodTransition( "pause", s3, "playing", handler ) );
-
- StateMachine sm = new StateMachine( new State[] { s1, s2, s3, s4, s5 }, "s1" );
- TapeDeck player = ( TapeDeck ) StateMachineProxyFactory.create( TapeDeck.class, sm );
- player.insert( "Kings of convenience - Riot on an empty street" );
+
+ State parent = new State("parent");
+ State s1 = new State("s1", parent);
+ State s2 = new State("s2", parent);
+ State s3 = new State("s3", parent);
+ State s4 = new State("s4", parent);
+ State s5 = new State("s5", parent);
+
+ parent.addTransition(new MethodTransition("*", "error", handler));
+ s1.addTransition(new MethodTransition("insert", s2, "inserted", handler));
+ s2.addTransition(new MethodTransition("start", s3, "playing", handler));
+ s3.addTransition(new MethodTransition("stop", s4, "stopped", handler));
+ s3.addTransition(new MethodTransition("pause", s5, "paused", handler));
+ s4.addTransition(new MethodTransition("eject", s1, "ejected", handler));
+ s5.addTransition(new MethodTransition("pause", s3, "playing", handler));
+
+ StateMachine sm = new StateMachine(new State[] { s1, s2, s3, s4, s5 }, "s1");
+ TapeDeck player = (TapeDeck) StateMachineProxyFactory.create(TapeDeck.class, sm);
+ player.insert("Kings of convenience - Riot on an empty street");
player.start();
player.pause();
player.pause();
player.eject();
player.stop();
player.eject();
-
+
LinkedList messages = handler.messages;
- assertEquals( "Tape 'Kings of convenience - Riot on an empty street' inserted", messages.removeFirst() );
- assertEquals( "Playing", messages.removeFirst() );
- assertEquals( "Paused", messages.removeFirst() );
- assertEquals( "Playing", messages.removeFirst() );
- assertEquals( "Error: Cannot eject at this time", messages.removeFirst() );
- assertEquals( "Stopped", messages.removeFirst() );
- assertEquals( "Tape ejected", messages.removeFirst() );
- assertTrue( messages.isEmpty() );
+ assertEquals("Tape 'Kings of convenience - Riot on an empty street' inserted", messages.removeFirst());
+ assertEquals("Playing", messages.removeFirst());
+ assertEquals("Paused", messages.removeFirst());
+ assertEquals("Playing", messages.removeFirst());
+ assertEquals("Error: Cannot eject at this time", messages.removeFirst());
+ assertEquals("Stopped", messages.removeFirst());
+ assertEquals("Tape ejected", messages.removeFirst());
+ assertTrue(messages.isEmpty());
}
- public void testTapeDeckStateMachineAnnotations() throws Exception
- {
+ public void testTapeDeckStateMachineAnnotations() throws Exception {
TapeDeckStateMachineHandler handler = new TapeDeckStateMachineHandler();
-
- StateMachine sm = StateMachineFactory.create( TapeDeckStateMachineHandler.S1, handler );
-
- TapeDeck player = ( TapeDeck ) StateMachineProxyFactory.create( TapeDeck.class, sm );
- player.insert( "Kings of convenience - Riot on an empty street" );
+
+ StateMachine sm = StateMachineFactory.create(TapeDeckStateMachineHandler.S1, handler);
+
+ TapeDeck player = (TapeDeck) StateMachineProxyFactory.create(TapeDeck.class, sm);
+ player.insert("Kings of convenience - Riot on an empty street");
player.start();
player.pause();
player.pause();
player.eject();
player.stop();
player.eject();
-
+
LinkedList messages = handler.messages;
- assertEquals( "Tape 'Kings of convenience - Riot on an empty street' inserted", messages.removeFirst() );
- assertEquals( "Playing", messages.removeFirst() );
- assertEquals( "Paused", messages.removeFirst() );
- assertEquals( "Playing", messages.removeFirst() );
- assertEquals( "Error: Cannot eject at this time", messages.removeFirst() );
- assertEquals( "Stopped", messages.removeFirst() );
- assertEquals( "Tape ejected", messages.removeFirst() );
- assertTrue( messages.isEmpty() );
+ assertEquals("Tape 'Kings of convenience - Riot on an empty street' inserted", messages.removeFirst());
+ assertEquals("Playing", messages.removeFirst());
+ assertEquals("Paused", messages.removeFirst());
+ assertEquals("Playing", messages.removeFirst());
+ assertEquals("Error: Cannot eject at this time", messages.removeFirst());
+ assertEquals("Stopped", messages.removeFirst());
+ assertEquals("Tape ejected", messages.removeFirst());
+ assertTrue(messages.isEmpty());
}
- public interface Reentrant
- {
- void call1( Reentrant proxy );
- void call2( Reentrant proxy );
- void call3( Reentrant proxy );
+ public interface Reentrant {
+ void call1(Reentrant proxy);
+ void call2(Reentrant proxy);
+ void call3(Reentrant proxy);
}
public static class ReentrantStateMachineHandler {
private boolean finished = false;
- public void call1( Reentrant proxy )
- {
- proxy.call2( proxy );
- }
- public void call2( Reentrant proxy )
- {
- proxy.call3( proxy );
+
+ public void call1(Reentrant proxy) {
+ proxy.call2(proxy);
+ }
+
+ public void call2(Reentrant proxy) {
+ proxy.call3(proxy);
}
- public void call3( Reentrant proxy )
- {
+
+ public void call3(Reentrant proxy) {
finished = true;
}
}
-
- public interface TapeDeck
- {
- void insert( String name );
+
+ public interface TapeDeck {
+ void insert(String name);
void eject();
void start();
void pause();
@@ -162,41 +157,35 @@
private LinkedList<String> messages = new LinkedList<String>();
- @Handler( on = "insert", in = "s1", next = "s2" )
- public void inserted( String name )
- {
- messages.add( "Tape '" + name + "' inserted" );
+ @Handler(on = "insert", in = "s1", next = "s2")
+ public void inserted(String name) {
+ messages.add("Tape '" + name + "' inserted");
}
-
- @Handler( on = "eject", in = "s4", next = "s1" )
- public void ejected()
- {
- messages.add( "Tape ejected" );
+
+ @Handler(on = "eject", in = "s4", next = "s1")
+ public void ejected() {
+ messages.add("Tape ejected");
}
- @Handlers( { @Handler( on = "start", in = "s2", next = "s3" ),
- @Handler( on = "pause", in = "s5", next = "s3" ) } )
- public void playing()
- {
- messages.add( "Playing" );
+ @Handlers({@Handler( on = "start", in = "s2", next = "s3" ),
+ @Handler( on = "pause", in = "s5", next = "s3" )})
+ public void playing() {
+ messages.add("Playing");
}
- @Handler( on = "pause", in = "s3", next = "s5" )
- public void paused()
- {
- messages.add( "Paused" );
+ @Handler(on = "pause", in = "s3", next = "s5")
+ public void paused() {
+ messages.add("Paused");
}
-
- @Handler( on = "stop", in = "s3", next = "s4" )
- public void stopped()
- {
- messages.add( "Stopped" );
+
+ @Handler(on = "stop", in = "s3", next = "s4")
+ public void stopped() {
+ messages.add("Stopped");
}
-
- @Handler( on = "*", in = "parent" )
- public void error( Event event )
- {
- messages.add( "Error: Cannot " + event.getId() + " at this time" );
+
+ @Handler(on = "*", in = "parent")
+ public void error(Event event) {
+ messages.add("Error: Cannot " + event.getId() + " at this time");
}
};
}