[jboss-cvs] JBossAS SVN: r82110 - in projects/ejb3/trunk/common/src/main/java/org/jboss/ejb3/common: kernel and 1 other directory.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon Dec 8 08:55:29 EST 2008
Author: alesj
Date: 2008-12-08 08:55:29 -0500 (Mon, 08 Dec 2008)
New Revision: 82110
Added:
projects/ejb3/trunk/common/src/main/java/org/jboss/ejb3/common/kernel/
projects/ejb3/trunk/common/src/main/java/org/jboss/ejb3/common/kernel/AbstractHandle.java
projects/ejb3/trunk/common/src/main/java/org/jboss/ejb3/common/kernel/DefaultHandleFactory.java
projects/ejb3/trunk/common/src/main/java/org/jboss/ejb3/common/kernel/Handle.java
projects/ejb3/trunk/common/src/main/java/org/jboss/ejb3/common/kernel/HandleFactory.java
projects/ejb3/trunk/common/src/main/java/org/jboss/ejb3/common/kernel/ScopeKeyHandle.java
projects/ejb3/trunk/common/src/main/java/org/jboss/ejb3/common/kernel/UniqueNameHandle.java
Log:
[EJBTHREE-1617]; MC bean handle.
TODO - tests, scoped context.
Added: projects/ejb3/trunk/common/src/main/java/org/jboss/ejb3/common/kernel/AbstractHandle.java
===================================================================
--- projects/ejb3/trunk/common/src/main/java/org/jboss/ejb3/common/kernel/AbstractHandle.java (rev 0)
+++ projects/ejb3/trunk/common/src/main/java/org/jboss/ejb3/common/kernel/AbstractHandle.java 2008-12-08 13:55:29 UTC (rev 82110)
@@ -0,0 +1,77 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.common.kernel;
+
+import org.jboss.dependency.spi.Controller;
+import org.jboss.dependency.spi.ControllerState;
+import org.jboss.dependency.spi.graph.GraphController;
+import org.jboss.dependency.spi.graph.SearchInfo;
+import org.jboss.kernel.Kernel;
+
+/**
+ * Abstract handle.
+ *
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+public abstract class AbstractHandle implements Handle
+{
+ private Object name;
+ private ControllerState state;
+
+ protected AbstractHandle(Object name)
+ {
+ if (name == null)
+ throw new IllegalArgumentException("Null name");
+
+ this.name = name;
+ }
+
+ public Object getBean(Kernel kernel) throws Throwable
+ {
+ if (kernel == null)
+ throw new IllegalArgumentException("Null kernel");
+
+ Controller controller = kernel.getController();
+ if (controller instanceof GraphController == false)
+ throw new IllegalArgumentException("Controller is not GraphController instance: " + controller);
+
+ GraphController gc = GraphController.class.cast(controller);
+ return gc.getContext(name, state, getSearchInfo());
+ }
+
+ /**
+ * Get the search info.
+ *
+ * @return the search info
+ */
+ protected abstract SearchInfo getSearchInfo();
+
+ /**
+ * Set the bean expected state.
+ *
+ * @param state the bean expected state
+ */
+ public void setState(ControllerState state)
+ {
+ this.state = state;
+ }
+}
Added: projects/ejb3/trunk/common/src/main/java/org/jboss/ejb3/common/kernel/DefaultHandleFactory.java
===================================================================
--- projects/ejb3/trunk/common/src/main/java/org/jboss/ejb3/common/kernel/DefaultHandleFactory.java (rev 0)
+++ projects/ejb3/trunk/common/src/main/java/org/jboss/ejb3/common/kernel/DefaultHandleFactory.java 2008-12-08 13:55:29 UTC (rev 82110)
@@ -0,0 +1,58 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.common.kernel;
+
+import org.jboss.dependency.spi.ControllerContext;
+
+/**
+ * The default handle factory.
+ *
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+public class DefaultHandleFactory implements HandleFactory
+{
+ public static final DefaultHandleFactory INSTANCE = new DefaultHandleFactory();
+
+ private DefaultHandleFactory()
+ {
+ }
+
+ /**
+ * Get the instance.
+ *
+ * @return the singleton instance
+ */
+ public static HandleFactory getInstance()
+ {
+ return INSTANCE;
+ }
+
+ public Handle createHandle(ControllerContext context)
+ {
+ if (context == null)
+ throw new IllegalArgumentException("Null context");
+
+ // TODO - check scoped context
+
+ return new UniqueNameHandle(context.getName());
+ }
+}
\ No newline at end of file
Added: projects/ejb3/trunk/common/src/main/java/org/jboss/ejb3/common/kernel/Handle.java
===================================================================
--- projects/ejb3/trunk/common/src/main/java/org/jboss/ejb3/common/kernel/Handle.java (rev 0)
+++ projects/ejb3/trunk/common/src/main/java/org/jboss/ejb3/common/kernel/Handle.java 2008-12-08 13:55:29 UTC (rev 82110)
@@ -0,0 +1,43 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.common.kernel;
+
+import java.io.Serializable;
+
+import org.jboss.kernel.Kernel;
+
+/**
+ * The MC bean handle.
+ *
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+public interface Handle extends Serializable
+{
+ /**
+ * Get the bean.
+ *
+ * @param kernel the MC kernel
+ * @return the handle's underlying bean
+ * @throws Throwable for any error or if the bean is not found
+ */
+ Object getBean(Kernel kernel) throws Throwable;
+}
Added: projects/ejb3/trunk/common/src/main/java/org/jboss/ejb3/common/kernel/HandleFactory.java
===================================================================
--- projects/ejb3/trunk/common/src/main/java/org/jboss/ejb3/common/kernel/HandleFactory.java (rev 0)
+++ projects/ejb3/trunk/common/src/main/java/org/jboss/ejb3/common/kernel/HandleFactory.java 2008-12-08 13:55:29 UTC (rev 82110)
@@ -0,0 +1,40 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.common.kernel;
+
+import org.jboss.dependency.spi.ControllerContext;
+
+/**
+ * The handle factory.
+ *
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+public interface HandleFactory
+{
+ /**
+ * Create the handle for context.
+ *
+ * @param context the controller context
+ * @return context's handle
+ */
+ Handle createHandle(ControllerContext context);
+}
\ No newline at end of file
Added: projects/ejb3/trunk/common/src/main/java/org/jboss/ejb3/common/kernel/ScopeKeyHandle.java
===================================================================
--- projects/ejb3/trunk/common/src/main/java/org/jboss/ejb3/common/kernel/ScopeKeyHandle.java (rev 0)
+++ projects/ejb3/trunk/common/src/main/java/org/jboss/ejb3/common/kernel/ScopeKeyHandle.java 2008-12-08 13:55:29 UTC (rev 82110)
@@ -0,0 +1,55 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.common.kernel;
+
+import org.jboss.dependency.plugins.graph.ScopeKeySearchInfo;
+import org.jboss.dependency.spi.graph.SearchInfo;
+import org.jboss.metadata.spi.scope.ScopeKey;
+
+/**
+ * Scope key handle.
+ * It looks up the bean via ScopeKey and non-unique bean name.
+ *
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+public class ScopeKeyHandle extends AbstractHandle
+{
+ private ScopeKey scopeKey;
+ private transient SearchInfo searchInfo;
+
+ public ScopeKeyHandle(ScopeKey scopeKey, Object name)
+ {
+ super(name);
+ if (scopeKey == null)
+ throw new IllegalArgumentException("Null scope key");
+
+ this.scopeKey = scopeKey;
+ }
+
+ protected SearchInfo getSearchInfo()
+ {
+ if (searchInfo == null)
+ searchInfo = new ScopeKeySearchInfo(scopeKey);
+
+ return searchInfo;
+ }
+}
\ No newline at end of file
Added: projects/ejb3/trunk/common/src/main/java/org/jboss/ejb3/common/kernel/UniqueNameHandle.java
===================================================================
--- projects/ejb3/trunk/common/src/main/java/org/jboss/ejb3/common/kernel/UniqueNameHandle.java (rev 0)
+++ projects/ejb3/trunk/common/src/main/java/org/jboss/ejb3/common/kernel/UniqueNameHandle.java 2008-12-08 13:55:29 UTC (rev 82110)
@@ -0,0 +1,45 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.common.kernel;
+
+import org.jboss.dependency.plugins.graph.Search;
+import org.jboss.dependency.spi.graph.SearchInfo;
+
+/**
+ * Unique name handle.
+ * It looks up the bean via unique bean name.
+ * Width first search.
+ *
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+public class UniqueNameHandle extends AbstractHandle
+{
+ public UniqueNameHandle(Object name)
+ {
+ super(name);
+ }
+
+ protected SearchInfo getSearchInfo()
+ {
+ return Search.WIDTH;
+ }
+}
More information about the jboss-cvs-commits
mailing list